home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
src.arc
/
UDPDUMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-12
|
848b
|
45 lines
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "netuser.h"
#include "internet.h"
#include "udp.h"
#include "ip.h"
/* Dump a UDP header */
void
udp_dump(bpp,source,dest,check)
struct mbuf **bpp;
int32 source,dest;
int check; /* If 0, bypass checksum verify */
{
struct udp udp;
struct pseudo_header ph;
int16 csum;
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
printf("UDP:");
/* Compute checksum */
ph.source = source;
ph.dest = dest;
ph.protocol = UDP_PTCL;
ph.length = len_mbuf(*bpp);
if((csum = cksum(&ph,*bpp,ph.length)) == 0)
check = 0; /* No checksum error */
ntohudp(&udp,bpp);
printf(" %u->%u",udp.source,udp.dest);
printf(" len %u",udp.length);
if(udp.checksum == 0)
check = 0;
if(check)
printf(" CHECKSUM ERROR (%u)",csum);
printf("\n");
}